const types = {
  HANDLE_LEFT_MENU: 'HANDLE_LEFT_MENU', // 收缩左侧菜单
  SET_LEFT_COLLAPSE: "SET_LEFT_COLLAPSE", // 改变左边菜单的收缩宽度
}
const menu = {
  state: {
    minLeftMenuWidth: 64,
    maxLeftMenuWidth: 220,
    sidebar: {
      opened: true,
      width: 220,
      collapseClass: 'iconzhedie_left',
      collapseName: '收起',
      center: 'center',
    },
    isCollapse: false, // 菜单默认展开
  },
  getters: {
    sidebar: state => state.sidebar,
    isCollapse: state => state.isCollapse,
  },
  mutations: {
    [types.HANDLE_LEFT_MENU](state) {
      if (state.sidebar.opened) { //true
        state.sidebar.width = state.minLeftMenuWidth;
        state.sidebar.center = 'center';
        state.sidebar.collapseClass = 'iconzhedie_right';
        state.sidebar.collapseName = '展开';
      } else {
        state.sidebar.width = state.maxLeftMenuWidth;
        state.sidebar.center = 'left';
        state.sidebar.collapseClass = 'iconzhedie_left';
        state.sidebar.collapseName = '收起';
      }
      state.sidebar.opened = !state.sidebar.opened;
    },
    [types.SET_LEFT_COLLAPSE](state) {
      state.isCollapse = !state.isCollapse;
    },
  },
  actions: {
    handleLeftMenu({
      commit
    }) {
      commit(types.HANDLE_LEFT_MENU)
    },
    setLeftCollapse({
      commit
    }) {
      commit(types.SET_LEFT_COLLAPSE)
    },
  }

}


export default menu;
